package com.finance.cooperate.feature.service.impl;

import com.finance.cooperate.common.utils.DateUtils;
import com.finance.cooperate.dao.entity.primary.CrcCreditos;
import com.finance.cooperate.dao.local.cache.CrcCache;
import com.finance.cooperate.dao.local.scope.CooperateRequestScope;
import com.finance.cooperate.dao.repository.primary.CrcCreditosRepository;
import com.finance.cooperate.feature.service.CrcCreditosService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName CrcCreditosServiceImpl
 * @Description 这个先不做了，太麻烦了
 * @Author shen
 * @Date 2023/8/9 23:03
 * @Modify ...
 */
@Slf4j
@Service
public class CrcCreditosServiceImpl implements CrcCreditosService {


    @Autowired
    private CrcCreditosRepository creditosRepository;

    @Autowired
    private CooperateRequestScope requestScope;


    @Override
    public Map<String, Object> getInfo(String uid) {

        Map<String, Object> result = new HashMap<>();

        String applyId = requestScope.getApplyId();

        List<CrcCreditos> creditos = creditosRepository.findByApplyId(applyId);

        if (creditos.size() > 0) {

            result.put("have_creditos", 1);

            for (CrcCreditos crc : creditos) {


                Date crcDate = DateUtils.toDate(crc.getFechaActualizacion(), DateUtils.YYYY_MM_DD);
                Date lastSubmitTime = crc.getCreateTime();

                Integer diffDays = DateUtils.getTimeDiffDays(crcDate, lastSubmitTime);

                if (diffDays >= 0) {

                    CrcCache.getTimeSplitsV1().forEach((k, v) -> {

                        if (diffDays <= v) {









                        }


















                    });





































                }










            }










        }







        return result;
    }



}
